import os
import numpy as np
from generation_data import GenerationData
from algorithm import Algorithm
from utils import Utils

def main():
    """
    主函数，执行整个数据生成和分析过程
    """
    print("开始生成模拟数据...")
    generate_row = 350
    generate_data = Algorithm.generate_input_output_data(generate_row, 5, 10, False)
    Utils.save_to_csv(generate_data, 'data/output_s.csv')
    
    # 生成累计数据
    generate_data_t = np.zeros((generate_row, 7), dtype=float)
    # 从第二行开始处理
    for i in range(1, generate_data.shape[0]):
        generate_data_t[i, 0] = generate_data[i, 0]  # 日期
        generate_data_t[i, 1] = generate_data[i, 1]  # record_row
        generate_data_t[i, 2] = generate_data[i, 2]  # input_ratio
        generate_data_t[i, 3] = generate_data[i, 3]  # output_ratio
        generate_data_t[i, 4] = np.round(np.sum(generate_data[:i + 1, 4]), 2)  # 累计投入
        generate_data_t[i, 5] = np.round(np.sum(generate_data[:i + 1, 5]), 2)  # 累计回报
        generate_data_t[i, 6] = np.round(np.sum(generate_data[:i + 1, 6]), 2)  # 累计盈亏
    
    Utils.save_to_csv(generate_data_t, 'data/output_t.csv')


if __name__ == "__main__":
    Utils.delete_files_in_folder('data')
    main()